package com.qg612324.account.model;

import java.util.List;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.ManyToMany;
import javax.persistence.Table;
import javax.persistence.Transient;

import org.springframework.security.core.GrantedAuthority;

@Entity
@Table(name = "roles")
public class Role implements GrantedAuthority{

    /**
     */
    private static final long serialVersionUID = -3786443968645887934L;

    private Integer id;

    private String name;

    private String description;
    
    private List<UrlResource> urlResourceList;

    @Id
    @GeneratedValue
    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    @Column(unique=true)
    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    @Override
    @Transient
    public String getAuthority() {
        return this.getName();
    }

    @ManyToMany(fetch=FetchType.EAGER)
    public List<UrlResource> getUrlResourceList() {
        return urlResourceList;
    }

    public void setUrlResourceList(List<UrlResource> urlResourceList) {
        this.urlResourceList = urlResourceList;
    }



    
}
